package cn.cloud.all.security.oauth2.common;

import cn.cloud.all.security.web.util.ThrowableAnalyzer;

import javax.servlet.ServletException;

/**
 * Default implementation of <code>ThrowableAnalyzer</code> which is capable of also unwrapping
 * <code>ServletException</code>s.
 */
public final class DefaultThrowableAnalyzer extends ThrowableAnalyzer {
    /**
     * @see cn.cloud.all.security.web.util.ThrowableAnalyzer#initExtractorMap()
     */
    protected void initExtractorMap() {
        super.initExtractorMap();
        registerExtractor(ServletException.class, throwable -> {
            ThrowableAnalyzer.verifyThrowableHierarchy(throwable, ServletException.class);
            return ((ServletException) throwable).getRootCause();
        });
    }
}
